#! /bin/bash

ROOT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")

function stop_container() {
  docker stop "tool_builder" > /dev/null 2>&1
  docker rm "tool_builder" > /dev/null 2>&1
  #wait docker stop
  sleep 1
}

function start_container() {
  stop_container

  docker run \
    -it \
    --rm \
    --ipc host \
    --net host \
    --name "tool_builder" \
    -v "$ROOT_DIR/../:/code" \
    -w /code \
    "hub.autox.tech/internal/safety-island/builder:20231212_1831" \
    /bin/bash
  if [ "$?" != 0 ]; then
    echo "Failed to start container!"
    exit 1
  fi
}

start_container